package com.woniu.work.controller;

import com.woniu.common.utils.ResponseData;
import com.woniu.work.Service.HhtProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author hht
 * @Date Create by 2024/11/26 10:10
 */
@RestController
@RequestMapping("/work")
public class HhtFlowableController {
    @Autowired
    private HhtProjectService hhtProjectService;


    @GetMapping("/deployFlow")
    public ResponseData<?> deployFlow(@RequestParam("bpmnFile") String bpmnFile) {
       return hhtProjectService.deployFlow(bpmnFile);
    }

    @GetMapping("/startProcess")
    public ResponseData<?> startProcess(@RequestParam("deploymentId") String deploymentId) {
        return hhtProjectService.startProcess(deploymentId);
    }

    @GetMapping("/completeTask")
    public void completeTask(@RequestParam("processInstanceId") String processInstanceId,
                             @RequestParam("approvalResult") Integer approvalResult,
                             @RequestParam("roleName") String roleName) {
        hhtProjectService.completeTask(processInstanceId, approvalResult, roleName);
    }

    @GetMapping("/deleteProcess")
    public void deleteProcess(@RequestParam("processInstanceId") String processInstanceId) {
        hhtProjectService.deleteProcess(processInstanceId);
    }

}
